package com.yociyy.sms.validate.code.images;

import com.yociyy.sms.validate.code.impl.AbstractValidateCodeProcessor;
import org.springframework.stereotype.Component;
import org.springframework.util.FastByteArrayOutputStream;

import javax.imageio.ImageIO;
import java.util.Map;

/**
 * 图形验证码处理器
 *
 * @author: YoCiyy
 * @date: 2020/5/26
 */
@Component("imageCodeProcessor")
public class ImageCodeProcessor extends AbstractValidateCodeProcessor<ImageCode> {

    @Override
    protected void send(Map<String, Object> params, ImageCode imageCode) throws Exception {
        FastByteArrayOutputStream os = new FastByteArrayOutputStream();
        ImageIO.write(imageCode.getImage(), "JPEG", os);
    }
}
